/*
 * CcAsm.c
 *
 *  Created on: 2012/04/26
 *      Author: guanxiaoying
 */
#include "../coredef.h"
#include "cc.h"

VOID AsmAnalysis( VOID ){
//	BOOL bAssemblyFlag = TRUE ;
	S4 RetInt=COEXIT_SUCCESS;
	AST astRTToken=0;
	AST astCurrToken = CcLexGetCurrToken();
	U4  currTokenKind;
	currTokenKind = stLexTokenAccess.tokenKind.get( astCurrToken );
	RetInt = CatchMemError();
	if( RetInt == COEXIT_FATAL ){
		return;
	}
	if ( currTokenKind != xLEX_INLINEASM ){
		return ;
	}
	astRTToken = CcLexGetRT(1) ;
	if ( stLexTokenAccess.tokenKind.get( astRTToken ) == xLEX_OPENPAREN ){
//		bAssemblyFlag = TRUE ;
	}
	else{
//		bAssemblyFlag = FALSE ;
		return;
	}

	CcLexGetNextToken();

	astCurrToken = CcLexGetNextToken();
	currTokenKind = stLexTokenAccess.tokenKind.get( astCurrToken );
	while ( currTokenKind != xLEX_SEMICOLON
			&& currTokenKind !=  xLEX_CLOSEPAREN
			&& currTokenKind !=  xLEX_ENDOFFILE ){
		astCurrToken = CcLexGetNextToken();
		currTokenKind = stLexTokenAccess.tokenKind.get( astCurrToken );
	}

	if (  currTokenKind != xLEX_CLOSEPAREN)	{
		CcThrowWarning( CC_ASM_SYNTAX_ERROR,
				stLexTokenAccess.codeScp.get( astCurrToken ),
				stLexTokenAccess.name.get( astCurrToken ), NULL );

	}else{
		astCurrToken = CcLexGetNextToken();
		currTokenKind = stLexTokenAccess.tokenKind.get( astCurrToken );
		if ( currTokenKind != xLEX_SEMICOLON){
			CcThrowWarning( CC_ASM_SYNTAX_ERROR,
					stLexTokenAccess.codeScp.get( astCurrToken ),
					stLexTokenAccess.name.get( astCurrToken ), NULL );
		}
	}
}
